package com.bolt.convention.data;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/3/6.
 */
public class MapResultMessage
        extends LinkedHashMap<String, Object> implements ResultMessage <Map <String, Object>>, Serializable {

    private static final String DEFAULT_KEY_STATUS = "status";
    private static final String DEFAULT_KEY_MESSAGE = "message";
    private static final String DEFAULT_KEY_DATA = "data";

    public static enum MESSAGE_RESULT_TYPE
    {
        success,  warning,  error,  confirm,  accessDenied;

        private MESSAGE_RESULT_TYPE() {}
    }

    public MapResultMessage put(String key, Object data) {
        super.put(key, data);
        return this;
    }

    public MapResultMessage put(Object data) {
        super.put(DEFAULT_KEY_DATA, data);
        return this;
    }

    @Override
    public String getCode() {
        return (String)this.get(DEFAULT_KEY_STATUS);
    }

    @Override
    public String getMessage() {
        return  (String)this.get(DEFAULT_KEY_MESSAGE);
    }

    @Override
    public Map getData() {
       return (Map)this.get(DEFAULT_KEY_DATA);
    }



    @Override
    public List <ViolationItem> getViolationItems() {
        return null;
    }

    @Override
    public String getErrorClass() {
        return null;
    }

    @Override
    public String getErrorStack() {
        return null;
    }

    @Override
    public MapResultMessage setCode(String code) {
        super.put(DEFAULT_KEY_STATUS, code);
        return this;
    }

    @Override
    public MapResultMessage setMessage(String message) {
        super.put(DEFAULT_KEY_MESSAGE, message);
        return this;
    }

    @Override
    public MapResultMessage setData(Map data) {
        super.put(DEFAULT_KEY_DATA, data);
        return this;
    }

    @Override
    public MapResultMessage setViolationItems(List <ViolationItem> violationItems) {

        return this;
    }

    @Override
    public MapResultMessage setErrorClass(String errorClass) {
        return this;
    }

    @Override
    public MapResultMessage setErrorStack(String errorStack) {
        return this;
    }

    @Override
    public MapResultMessage addViolationItem(String field, String message) {

        return this;
    }

    @Override
    public boolean isSuccess() {
        return true;
    }

    @Override
    public boolean isError() {
        return true;
    }


    @Override
    public boolean isFailure() {
        return (!isSuccess()) && (!isError());
    }









}




 